package cn.lzh.quartzadmin.cfg;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public TokenInterceptor tokenInterceptor() {
        return new TokenInterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册Token拦截器
        registry.addInterceptor(tokenInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/index.html"
                        , "/"
                        , "/favicon.ico"
                        , "/v2/api-docs"
                        , "/doc.html"
                        , "/swagger-ui.html"
                        , "/webjars/springfox-swagger-ui/**"
                        , "/swagger-resources/**"
                        , "/monitor/job/list"
                        , "/monitor/job/detail/**"
                        , "/monitor/job/checkCronExpressionIsValid"
                        , "/monitor/jobLog/detail/**"
                        , "/monitor/jobLog/clean"
                        , "/monitor/jobLog/list");


    }
}